package com.demo.controller;

import com.demo.dao.SectMapper;
import com.demo.dto.Sect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sect")
public class SectController {

    @Autowired
    private SectMapper sectMapper;

    @RequestMapping("/add")
    public Sect add(@RequestBody @Validated Sect sect){
        sectMapper.add(sect);
        return sect;
    }

    @RequestMapping("/list")
    public List<Sect> list(){
        return sectMapper.list(-1);
    }


}
